﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: Propietario			*/
/* País: Colombia, Bogotá			*/

#endregion

#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ESF.General.MVP;
using ESF.SSO.Core.BusinessLogic;
using ESF.SSO.Core.Entities;
using ESF.General.Entity;
using ESF.General;

#endregion 


namespace ESF.SSO.Presenter.Client
{
	public class ContactUsPresenter : BasePresenter<IContactUsViewer>
	{
		#region Constructor
		
		public ContactUsPresenter (IContactUsViewer pViewer) : base (pViewer) {}
		
		#endregion
		
	
		#region Funciones
		
		public override void Load()
		{
			
		}
		
		
		public override void Clear ()
		{
			ClearError ();
			
			_Viewer.Comment = string.Empty;
			_Viewer.CommentTitle = string.Empty;
			_Viewer.ContactUsTypeID = null;
			
			if (!_Viewer.frmIsAuthenticated)
			{
				_Viewer.UserEmail = string.Empty;
			}
		}
		
		
		public void SendComment ()
		{
			try
			{
				CtrlContactUs.Insert (
					new ESF.SSO.Core.Entities.ContactUs ()
					{
						Application = new BasicReference () { Code = ReadConfig.ApplicationCode },
						Comments = _Viewer.Comment,
						SenderEmail = _Viewer.UserEmail,
						Title = _Viewer.CommentTitle,
						ContactUsTypeID = new BasicReference () { ID = _Viewer.ContactUsTypeID }
					});
				
				Clear ();
				
				_Viewer.frmInfoMsg = "Sus comentarios han sido registrados";
			}
			catch (Exception pEx)
			{
				LogError (pEx);
			}
		}
		
		#endregion
	}
}
